﻿using System;
using System.Windows.Forms;
using System.Drawing;

namespace LinxDtefTelas
{
    public class cCreateDynamicObjects
    {
        public string sResposta = "";

        //Aqui
 

        public Label CreateDynamicLabel(string sName, string sText, int lcX, int lcY, int szX, int szY, int optAlign)
        {
            //optAlign 1 ou 2 
            //1 - Label do cabeçalho
            //2 - Label do Rodapé ou corpo do Form.
            if (optAlign == 1)
            {
                Label oLabel = new Label();
                oLabel.Location = new System.Drawing.Point(lcX, lcY);
                oLabel.Size = new System.Drawing.Size(szX, szY);
                oLabel.ForeColor = System.Drawing.Color.White;
                oLabel.BackColor = System.Drawing.Color.DarkCyan;
                oLabel.Font = new System.Drawing.Font("BankGothic Lt BT", 10.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                oLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
                oLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                oLabel.Name = sName;
                oLabel.Text = sText;

                return oLabel;
            }
            else
            {
                Label oLabel = new Label();
                oLabel.Location = new System.Drawing.Point(lcX, lcY);
//                oLabel.Size = new System.Drawing.Size(szX, szY);
                oLabel.AutoSize = true;
                oLabel.ForeColor = System.Drawing.Color.Black;
                oLabel.BackColor = System.Drawing.Color.Transparent;
                oLabel.Font = new System.Drawing.Font("BankGothic Lt BT", 10.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                oLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
                oLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                oLabel.Name = sName;
                oLabel.Text = sText;

                return oLabel;
            }
        }


        public MaskedTextBox createDynamicTextBox(string sName, int lcX, int lcY, int szX, int szY, string mask, string text)
        {
            MaskedTextBox oTxt = new MaskedTextBox();
            oTxt.Location = new System.Drawing.Point(lcX,lcY);
            oTxt.Size = new System.Drawing.Size(szX, szY);
            oTxt.Name = sName;
            oTxt.TabIndex = 1;
            oTxt.Mask = mask;
            oTxt.Text = text;
            oTxt.TextAlign = HorizontalAlignment.Right;
            oTxt.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

            return oTxt;
        }

        public PictureBox CreateDynamicPicBox(Image iconName, string picBoxName)
        {
            Bitmap bmp = new Bitmap(iconName);
            PictureBox dynamicPicBox = new PictureBox();
            
            dynamicPicBox.Image = bmp;
                //(Resources.GetObject("pictureBox1.Image"));
            dynamicPicBox.Location = new System.Drawing.Point(418, 9);
            dynamicPicBox.Name = picBoxName;
            dynamicPicBox.Size = new System.Drawing.Size(74, 68);
            dynamicPicBox.TabIndex = 5;
            dynamicPicBox.TabStop = false;

            return dynamicPicBox;
        }

     

        public Button CreateDynamicButton(Image imageName, string btnName, string btnText, int lcX, int LcY, int szX, int szY)
        {
            //imageName = Resources.Equals();
            Button dynamicButton = new Button(); 

            dynamicButton.FlatAppearance.BorderColor = System.Drawing.Color.White;
            dynamicButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            dynamicButton.Font = new System.Drawing.Font("Tahoma", 7.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            dynamicButton.Image = new Bitmap(imageName);
            dynamicButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            dynamicButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
            dynamicButton.Location = new System.Drawing.Point(lcX,LcY);
            dynamicButton.Name = btnName;
            dynamicButton.Size = new System.Drawing.Size(szX,szY);
            dynamicButton.TabIndex = 2;
            dynamicButton.Text = btnText;
            dynamicButton.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            dynamicButton.UseVisualStyleBackColor = true;
            //dynamicButton.Click += new System.EventHandler(dynamicButton_Click);

            return dynamicButton;
        }

        public FormDTEF CreateDynamicForm(string formName, int szX, int szY, Image pibBoxImage, String pictureBoxName)
        {
            FormDTEF dynamicForm = new FormDTEF();

            dynamicForm.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            dynamicForm.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            dynamicForm.BackColor = System.Drawing.SystemColors.Window;
            dynamicForm.ClientSize = new System.Drawing.Size(szX, szY);
            dynamicForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            dynamicForm.MaximizeBox = false;
            dynamicForm.MinimizeBox = false;
            dynamicForm.Name = formName;
            dynamicForm.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            dynamicForm.Text = "DADOS DA TRANSAÇÃO";
            dynamicForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            dynamicForm.KeyPreview = true;
            dynamicForm.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            //dynamicForm.KeyPress += new System.Windows.Forms.KeyPressEventHandler(dynamicForm_KeyPress);
            dynamicForm.ResumeLayout(false);
            dynamicForm.PerformLayout();
            

            if (pibBoxImage != null)
            {
                dynamicForm.Controls.Add(this.CreateDynamicPicBox(pibBoxImage, pictureBoxName));
            }
            dynamicForm.ResumeLayout(false);
            dynamicForm.PerformLayout();


            return dynamicForm;

        }

      


    }
}
